<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">
    <ui:define name="head">
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                    else
                        event.srcElement.click();
                }
            }
        </script>
        <style type="text/css">
            .c_c {
                background: gray;
            }
            .p_c {
                background: green;
            }
        </style>
    </ui:define>
    <ui:define name="content">
        <div style="margin:5px;">
            <h:form id="form">
                <p:growl id="msgs" showDetail="false"/>
                <p:panel id="inputItemHieRelap"
                         header="#{esCommonAction.itemTypeListValueOfAlias(itemHieRelapCstplAction.itemOfEsItemHieRelap.belongToType)}"
                         style="width: 100%">
                    <h:panelGrid columns="2" style="width: 100%">
                        <h:panelGrid id="pgItemHieRelapInput" widgetVar="wvItemHieRelap"
                                     columns="8" style="width: 100%" >

                            <h:outputLabel for="noItemHieRelap" value="编号:" />
                            <h:inputText id="noItemHieRelap"
                                         value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.strNo}"
                                         style="#{itemHieRelapCstplAction.disabledFlags[0].disabled_style}"
                                         disabled="#{itemHieRelapCstplAction.disabledFlags[0].disabled_flag}">
                                <p:ajax event="blur" update="msgs,pgInputBlur,pgItemHieRelapBtn,correspondingItemNoItemInfo"
                                        listener="#{itemHieRelapCstplAction.blurStrNoToGradeAndOrderid('true')}"/>
                            </h:inputText>

                            <h:outputLabel for="name" value="名称:" />
                            <p:selectOneMenu id="name"
                                             value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.name}"
                                             editable="true"
                                             style="#{itemHieRelapCstplAction.disabledFlags[1].disabled_style};"
                                             disabled="#{itemHieRelapCstplAction.disabledFlags[1].disabled_flag}">
                                <f:selectItem itemLabel="固定项输入时请选择下列名称" itemValue="" />
                                <f:selectItems value="#{esCommonAction.cstplItemNamelist}" />
                                <p:ajax update="msgs,pgItemHieRelapInput"
                                        listener="#{itemHieRelapCstplAction.blurStrName}"/>
                            </p:selectOneMenu>

                            <h:outputLabel for="unitItemInfo" value="单位:"/>
                            <h:inputText id="unitItemInfo"
                                         value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.unit}"
                                         style="#{itemHieRelapCstplAction.disabledFlags[2].disabled_style}"
                                         disabled="#{itemHieRelapCstplAction.disabledFlags[2].disabled_flag}"/>

                            <h:outputLabel for="contractUnitPriceItemInfo" value="合同单价:"/>
                            <h:inputText id="contractUnitPriceItemInfo"
                                         value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.contractUnitPrice}"
                                         style="#{itemHieRelapCstplAction.disabledFlags[3].disabled_style};
                                         text-align:right;float:left"
                                         disabled="#{itemHieRelapCstplAction.disabledFlags[3].disabled_flag}">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                                <p:ajax event="blur" update="contractAmountItemInfo"
                                        listener="#{itemHieRelapCstplAction.blurCalculateAmountAction}"/>
                            </h:inputText>

                            <h:outputLabel for="contractQuantityItemInfo" value="合同数量:"/>
                            <h:inputText id="contractQuantityItemInfo"
                                         value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.contractQuantity}"
                                         style="#{itemHieRelapCstplAction.disabledFlags[4].disabled_style};
                                         text-align:right;float:left"
                                         disabled="#{itemHieRelapCstplAction.disabledFlags[4].disabled_flag}">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                                <p:ajax event="blur" update="contractAmountItemInfo"
                                        listener="#{itemHieRelapCstplAction.blurCalculateAmountAction}"/>
                            </h:inputText>

                            <h:outputLabel for="contractAmountItemInfo" value="合同金额:"/>
                            <h:inputText id="contractAmountItemInfo"
                                         value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.contractAmount}"
                                         style="#{itemHieRelapCstplAction.disabledFlags[5].disabled_style};
                                         text-align:right;float:left"
                                         disabled="#{itemHieRelapCstplAction.disabledFlags[5].disabled_flag}">
                                <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                            </h:inputText>

                            <h:outputLabel for="note" value="备注内容:" />
                            <h:inputTextarea id="note"
                                             value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.note}"
                                             rows="1" autoResize="false"
                                             style="#{itemHieRelapCstplAction.disabledFlags[6].disabled_style}"
                                             disabled="#{itemHieRelapCstplAction.disabledFlags[6].disabled_flag}"/>

                            <h:outputLabel for="correspondingItemNoItemInfo" value="对应编号:" />
                            <h:inputText id="correspondingItemNoItemInfo"
                                         value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.strCorrespondingItemNo}"
                                         style="#{itemHieRelapCstplAction.disabledFlags[7].disabled_style}"
                                         disabled="#{itemHieRelapCstplAction.disabledFlags[7].disabled_flag}">
                                <p:ajax event="blur" update="msgs,correspondingPkidItemHieRelap"
                                         listener="#{itemHieRelapCstplAction.blurCorrespondingPkid}"/>
                            </h:inputText>
                        </h:panelGrid>
                        <h:panelGrid id="pgItemHieRelapBtn" columns="1"  style="width:100%">
                            <p:commandButton id="submitBtn" value="#{itemHieRelapCstplAction.strSubmitBtnName}"
                                             action="#{itemHieRelapCstplAction.submitThisRecordAction}"
                                             update="ptt,msgs,inputItemHieRelap">
                            </p:commandButton>
                            <p:commandButton id="resetBtn" value="重置"
                                             action="#{itemHieRelapCstplAction.reSetAction}"
                                             update="inputItemHieRelap">
                            </p:commandButton>
                        </h:panelGrid>
                        <h:panelGrid id="pgInputBlur" columns="8" rendered="false">
                            <h:outputLabel for="pkidItemHieRelap" value="Pkid:" />
                            <h:inputTextarea id="pkidItemHieRelap"
                                             value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.pkid}"
                                             style="font-weight:bold;width:200px"
                                             disabled="true"/>
                            <h:outputLabel for="parentPkidItemHieRelap" value="父层Pkid:" />
                            <h:inputTextarea id="parentPkidItemHieRelap"
                                             value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.parentPkid}"
                                             style="font-weight:bold;width:200px"
                                             disabled="true"/>
                            <h:outputLabel for="itemPkidItemHieRelap" value="项Pkid:" />
                            <h:inputTextarea id="itemPkidItemHieRelap"
                                             value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.itemPkid}"
                                             style="font-weight:bold;width:200px"
                                             disabled="true"/>
                            <h:outputLabel for="correspondingPkidItemHieRelap" value="对应Pkid:" />
                            <h:inputTextarea id="correspondingPkidItemHieRelap"
                                             value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.correspondingPkid}"
                                             style="font-weight:bold;width:200px"
                                             disabled="true"/>
                            <h:outputLabel for="gradeItemHieRelap" value="层号:" />
                            <h:inputText id="gradeItemHieRelap"
                                             value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.grade}"
                                             style="font-weight:bold"
                                             disabled="true"/>
                            <h:outputLabel for="orderidItemHieRelap" value="序号:" />
                            <h:inputText id="orderidItemHieRelap"
                                             value="#{itemHieRelapCstplAction.itemOfEsItemHieRelap.orderid}"
                                             style="font-weight:bold"
                                             disabled="true"/>
                        </h:panelGrid>
                    </h:panelGrid>
                </p:panel>

                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="/images/ajaxloading.gif"/>
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value=""/>
                    </f:facet>
                </p:ajaxStatus>

                <p:contextMenu for="ptt" id="pcm">
                    <p:menuitem value="更新" icon="ui-icon-arrowrefresh-1-w"
                                actionListener="#{itemHieRelapCstplAction.selectRecordAction('upd')}"
                                update="inputItemHieRelap,msgs">
                    </p:menuitem>
                    <p:menuitem value="删除" icon="ui-icon-close"
                                actionListener="#{itemHieRelapCstplAction.selectRecordAction('del')}"
                                update="inputItemHieRelap,msgs">
                    </p:menuitem>
                    <p:menuitem value="总包合同⇒成本计划" icon="ui-icon-copy"
                                actionListener="#{itemHieRelapCstplAction.selectRecordAction('from_tkctt_to_cstpl')}"
                                update="inputItemHieRelap,msgs,ptt">
                    </p:menuitem>
                </p:contextMenu>

                <p:dataTable id="ptt" style="width:100%;"
                             value="#{itemHieRelapCstplAction.itemOfTkcttAndCstplList}"
                             var="record"
                             rowKey="#{record.pkid}"
                             selection="#{itemHieRelapCstplAction.itemOfTkcttAndCstplSelected}"
                             selectionMode="single"
                             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
                             {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             paginator="true"
                             paginatorPosition="bottom"
                             rows="20"
                             rowsPerPageTemplate="200,100,50,40,30,20,10"
                             rowIndexVar="row"
                             emptyMessage="数据记录为空..."
                             rowStyleClass="#{record.name eq '合计'? 'c_c': record.nameContrast eq '合计'? 'c_c':
                                                 record.name eq '总合计'? 'c_c':record.nameContrast eq '总合计'? 'c_c':null}"
                             scrollable="true"
                             scrollHeight="475">
                    <p:column style="width:30px" headerText="序号">
                        <h:outputText value="#{row + 1}"/>
                    </p:column>

                    <p:column style="width:100px" headerText="总包编号">
                        <h:outputText value="#{record.strNo}" escape="false"/>
                    </p:column>

                    <p:column style="width:200px" headerText="总包名称">
                        <h:outputText value="#{record.name}" />
                    </p:column>

                    <p:column style="width:60px" headerText="总包单位">
                        <h:outputText value="#{record.unit}" style="text-align:right"/>
                    </p:column>

                    <p:column style="width:80px" headerText="总包单价">
                        <h:outputText value="#{record.contractUnitPrice}" style="float: right" >
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:80px" headerText="总包数量">
                        <h:outputText value="#{record.contractQuantity}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:100px" headerText="总包金额">
                        <h:outputText value="#{record.contractAmount}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <!--成本计划-->
                    <p:column style="width:100px" headerText="成本编号">
                        <h:outputText value="#{record.strNoContrast}" escape="false"/>
                    </p:column>

                    <p:column style="width:200px" headerText="成本名称">
                        <h:outputText value="#{record.nameContrast}" />
                    </p:column>

                    <p:column style="width:60px" headerText="成本单位">
                        <h:outputText value="#{record.unitContrast}" style="text-align:right"/>
                    </p:column>

                    <p:column style="width:80px" headerText="成本单价">
                        <h:outputText value="#{record.contractUnitPriceContrast}" style="float: right" >
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:80px" headerText="成本数量">
                        <h:outputText value="#{record.contractQuantityContrast}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:100px" headerText="成本金额">
                        <h:outputText value="#{record.contractAmountContrast}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <p:column style="width:300px" headerText="成本备注">
                        <h:outputText value="#{record.noteContrast}" />
                    </p:column>

                    <f:facet name="footer">
                        <div style="text-align: left">
                            <p:commandButton id="mngFinishBtn" value="录入结束"
                                             action="#{itemHieRelapCstplAction.mngFinish_SetInitToStatusFlagAction('1')}"
                                             update=":form:msgs"
                                             rendered="#{itemHieRelapCstplAction.strIsNullAndInitRendered}"/>
                            <p:commandButton id="mngNotFinishBtn" value="重新录入"
                                             action="#{itemHieRelapCstplAction.mngNotFinishAction('1')}"
                                             update=":form:msgs"
                                             rendered="#{itemHieRelapCstplAction.strIsNullAndInitRendered}"/>
                        </div>
                    </f:facet>
                </p:dataTable>
            </h:form>
        </div>
    </ui:define>
</ui:composition>

<!--（1）输出的时间与原来的时间差8个小时,原因是没加上时间的属性,改成:
<h:outputText value="#{data.t_Date}">
    <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="GMT+8" locale="cn" />
</h:outputText>
加上 timeZone="GMT+8"之后，则显示正常的时间
（2）有的需要显示是12小时格式，有的需要显示24小时格式
主要在 pattern="yyyy-MM-dd HH:mm:ss"这句的hh上面，要是大写的HH则是24小时格式，小写hh则是12小时格式-->
